﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sinacor.Service.Infra.AuthorizationService.Service.ServiceImplementation.Translator
{
	public static class TranslateBetweenModule
	{
		public static DataContract.Response.ModuleResponse ToDataContract(BusinessEntity.Module from)
		{
			DataContract.Response.ModuleResponse to = new DataContract.Response.ModuleResponse();
			to.Id = from.Id;
			to.Name = from.Name;
			if(from.Items.Count > 0)
				to.Items = TranslateBetweenMenuItem.ToDataContractList(from.Items);
            if (from.Roles.Count > 0)
                to.Roles = TranslateBetweenRole.ToDataContractList(from.Roles);
			return to;
		}

		public static List<DataContract.Response.ModuleResponse> ToDataContractList(List<BusinessEntity.Module> from)
		{
			List<DataContract.Response.ModuleResponse> to = new List<DataContract.Response.ModuleResponse>();
			foreach (BusinessEntity.Module item in from)
			{
				to.Add(ToDataContract(item));
			}
			return to;
		}
	}
}